<template>
    <el-descriptions ref="ruleFormRef" :column="2" direction="vertical" v-loading="isLoading">
        <el-descriptions-item width="50%" label='姓名'>
            {{ formInline?.nickname }}
        </el-descriptions-item>
        <el-descriptions-item width="50%" label='手机号'>
            {{ formInline?.phone }}
        </el-descriptions-item>
        <el-descriptions-item width="50%" label='登录账号'>
            {{ formInline?.loginName }}
        </el-descriptions-item>
        <el-descriptions-item width="50%" label='关注公众号'>
            <div v-if="formInline?.openid !== ''">
                已关注 <sj-link class="ml-[10px]" custom-type="sblue" :underline="false" @click="openWx">换绑</sj-link>
            </div>
            <sj-link v-else custom-type="sblue" :underline="false" @click="openWx">前往关注</sj-link>
        </el-descriptions-item>
        <el-descriptions-item width="50%" label='所属单位'>
            {{ formInline?.unityName }}
        </el-descriptions-item>
        <!-- <el-descriptions-item width="50%" label='用户角色'>
            {{ formInline?.roles?.map(item => item.roleName).join(',') }}
        </el-descriptions-item> -->
        <el-descriptions-item width="50%" label='最后登录IP'>
            {{ formInline?.lastLoginIP }}
        </el-descriptions-item>
        <el-descriptions-item width="50%" label='最后登录时间'>
            {{ formInline?.lastLoginTime }}
        </el-descriptions-item>
    </el-descriptions>
</template>
<script setup lang="ts">
import { addDialog } from "@/components/ReDialog";
import wxPopup from "./wxPopup.vue";
import { ref } from "vue";
import { getSelfInfo, } from "@/api/user";
type FormProps = {
    formInline: any,
    isLoading: boolean
}
const formRef = ref();
const props = withDefaults(defineProps<FormProps>(), {
    formInline: () => ({} as any),
    isLoading: false
});

const ruleFormRef = ref();

function getRef() {
    return ruleFormRef.value;
}
const openWx = (row) => {
    addDialog({
        title: `微信绑定`,
        showClose: true,
        width: "400px",
        draggable: true,
        hideFooter: true,
        fullscreenIcon: false,
        closeOnClickModal: false,
        close({ options, index }) {

            getSelfInfo()
                .then(res => {
                    props.formInline.openid = res.result.userInfo.openid;
                    console.log('hhh');
                })
                .finally(() => {

                });

        },
        contentRenderer: () => h(wxPopup, { ref: formRef }),
    })
}
defineExpose({ getRef });
</script>